package com.tjsinfo.tjsoa.workplan.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.workplan.vo.WorkPlanMain;

public class CheckDefalntWorkPlanDateModleActionDown extends WorkPlanDateModleDownAction{
	private ISystemUserBo systemUserBo;
	
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.workplan.action.WorkPlanDateModleDownAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		User user = getUser(request);
		Date date = getDate(request);
		TSystemUser systemUser = systemUserBo.findByIdSystemUser(Integer.parseInt(request.getParameter("userid")));
		request.setAttribute("systemUser", systemUser);
		request.setAttribute("userinfoid", user.getUser_id());
		Map<Date, WorkPlanMain> map = workPlanMainBo.selectWorkPlanTypeAndYearMAPTimeStart("D", date.getYear() + 1900, user.getUser_id(), 1);
		request.setAttribute("yueli", date);
		request.setAttribute("workplanmap", map);
		return mapping.findForward("ok");
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.workplan.action.WorkPlanDateModleDownAction#getUser(javax.servlet.http.HttpServletRequest)
	 */
	@Override
	protected User getUser(HttpServletRequest request) {
		// TODO Auto-generated method stub
		Integer id  = Integer.parseInt(request.getParameter("userid"));
		User user = new User();
		user.setUser_id(id);
		return user;
	}
	
}
